using System;
using System.Threading.Tasks;
using CKY.AgentPlatform.Domain.McpTools;

namespace CKY.AgentPlatform.Services
{
    /// <summary>
    /// MCP工具执行服务接口
    /// </summary>
    public interface IMcpToolExecutionService
    {
        /// <summary>
        /// 执行MCP工具
        /// </summary>
        /// <param name="toolId">工具ID</param>
        /// <param name="input">执行输入</param>
        /// <returns>执行结果</returns>
        Task<object> ExecuteAsync(Guid toolId, McpToolExecutionInput input);

        /// <summary>
        /// 批量执行MCP工具
        /// </summary>
        /// <param name="toolId">工具ID</param>
        /// <param name="inputs">执行输入列表</param>
        /// <returns>执行结果列表</returns>
        Task<object[]> BatchExecuteAsync(Guid toolId, McpToolExecutionInput[] inputs);

        /// <summary>
        /// 获取工具执行状态
        /// </summary>
        /// <param name="executionId">执行ID</param>
        /// <returns>执行状态</returns>
        Task<McpToolExecutionStatus> GetExecutionStatusAsync(Guid executionId);

        /// <summary>
        /// 取消工具执行
        /// </summary>
        /// <param name="executionId">执行ID</param>
        /// <returns>是否成功</returns>
        Task<bool> CancelExecutionAsync(Guid executionId);
    }

    /// <summary>
    /// MCP工具执行状态
    /// </summary>
    public class McpToolExecutionStatus
    {
        /// <summary>
        /// 执行ID
        /// </summary>
        public Guid ExecutionId { get; set; }

        /// <summary>
        /// 执行状态
        /// </summary>
        public string Status { get; set; }

        /// <summary>
        /// 进度（0-100）
        /// </summary>
        public int Progress { get; set; }

        /// <summary>
        /// 执行结果
        /// </summary>
        public object Result { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string Error { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndTime { get; set; }
    }
}